package cloud.pangui.core.lock.autoconfig;


import cloud.pangui.core.lock.aop.LockAspect;
import cloud.pangui.core.lock.executor.LockExecutor;
import cloud.pangui.core.lock.executor.impl.RedisTemplateLockExecutor;
import cloud.pangui.core.lock.resolver.LockResolverFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Auther hepangui
 * @Date 2019/5/10 0010
 */
@Configuration
public class GlobalLockAutoConfiguration {
	@Bean
	public LockAspect lockAspect(){
		return new LockAspect();
	}

	@Bean
	@ConditionalOnMissingBean(LockExecutor.class)
	public LockExecutor lockExecutor(){
		return new RedisTemplateLockExecutor();
	}

	@Bean
	public LockResolverFactory lockResolverFactory(){
		return new LockResolverFactory();
	}

	@Bean
	public GlobalLockBeanPostProcessor postProcessor(){
		return new GlobalLockBeanPostProcessor();
	}
}
